<?php
namespace Admin\Controller;

use Common\Controller\AdminBaseController;

/**
 * 后台代理控制器
 */
class AgentController extends AdminBaseController
{

    public function salary_setting()
    {

        $sale = M('salary_setting')->select();

        $this->assign('sale', $sale);
        $this->display();
    }
    public function change_salary()
    {
        $count = M('salary_setting')->count();
        for ($i = 0; $i < $count; $i++) {
            $ii = $i + 1;

            $condition['id'] = $ii;

            $update_array['percentage'] = $_POST['percentage'][$i];

            $update_array['sales'] = $_POST['sales'][$i];

            $result = M('salary_setting')->where($condition)->save($update_array);
        }
        if ($result >= 0) {

            admin_log('编辑代理工资参数 采种' . $c_id . '');
            $this->success('修改代理工资参数成功', U('Admin/Agent/salary_setting'));exit;
        } else {
            $this->error('修改代理工资参数失败', U('Admin/Agent/salary_setting'));exit;
        }
    }
    //分红
    public function fenhong_setting()
    {
        $fenhong = M('fenhong_setting')->select();

        $this->assign('fenhong', $fenhong);
        $this->display();
    }
    public function change_fenhong()
    {
        $count = M('fenhong_setting')->count();
        for ($i = 0; $i < $count; $i++) {
            $ii = $i + 1;

            $condition['id'] = $ii;

            $update_array['percentage'] = $_POST['percentage'][$i];

            $update_array['sales'] = $_POST['sales'][$i];

            $result = M('fenhong_setting')->where($condition)->save($update_array);
        }
        if ($result >= 0) {

            admin_log('编辑代理分红参数 采种' . $c_id . '');
            $this->success('修改代理分红参数成功', U('Admin/Agent/fenhong_setting'));exit;
        } else {
            $this->error('修改代理分红参数失败', U('Admin/Agent/fenhong_setting'));exit;
        }
    }

    //工资列表
    public function salary_list()
    {
        $salary = M('dl_salary')->order('id desc')->select();

        $this->assign('info', $salary);
        $this->display();
    }
    //分红列表
    public function fenhong_list()
    {
        $dl_fenhong = M('dl_fenhong')->order('id desc')->select();

        $this->assign('info', $dl_fenhong);

        $this->display();
    }

}
